<?php
namespace app\index\controller;

use think\Controller;
use think\Request;
use think\Session;
use think\View;

class Base extends Controller
{

    /**
     * 清除session
     */
    public function clear_session() {
        Session::clear();
        $this->redirect(url('member/index'));
    }

    /**
     * 微信关注引导页面
     */
    public function subscribe() {
        return view();
    }

    /**
     * 发送短信验证码
     */
    public function send_code() {
        $mobile = input('param.mobile');
        $data = \app\api\service\NoteCode::send_code(['mobile' => $mobile]);
        return json($data);
    }

    /**
     * 根据经纬度获取地址信息
     * @return \think\response\Json
     */
    public function get_geocoder() {
        $location = input('param.lat') . ',' . input('param.lng');
        $data = \Map\Map::getGeocoder($location);
        return json($data);
    }

    /**
     * 检查是否登录
     */
    public function is_login() {
        if (!session('?member_id') || !session('?member_username')) {
            $this->error('未登录');
        } else {
            $this->success('已登录');
        }
    }

    /**
     * 图片上传
     */
    public function upload_image() {
        $data = \app\api\service\Upload::upload_image();
        return json($data);
    }
}
